// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   LoginFilter.java

package cn.com.pusai.common.filter;

//import cn.com.pusai.base.login.model.LoginObject;
import cn.com.pusai.common.config.SysProperties;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.*;
import javax.servlet.http.*;

public class LoginFilter
	implements Filter
{

	private Map logoutUrlMap;
	private FilterConfig filterConfig;

	public LoginFilter()
	{
		logoutUrlMap = new HashMap();
		filterConfig = null;
	}

	public void init(FilterConfig filterConfig)
		throws ServletException
	{
		this.filterConfig = filterConfig;
//		String loginObjNameNameStr = filterConfig.getInitParameter("LOGIN_OBJECT_NAMES");
//		String forwardLoginUrlStr = filterConfig.getInitParameter("FORWARD_LOGIN_URLS");
//		String loginObjNameNames[] = loginObjNameNameStr.split(",");
//		String forwardLoginUrls[] = forwardLoginUrlStr.split(",");
//		for (int i = 0; i < loginObjNameNames.length; i++)
//			logoutUrlMap.put(loginObjNameNames[i], forwardLoginUrls[i]);

	}

	public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
		throws IOException, ServletException
	{
//		HttpServletRequest request = (HttpServletRequest)servletRequest;
//		HttpServletResponse response = (HttpServletResponse)servletResponse;
//		HttpSession session = request.getSession();
//		LoginObject loginObject = (LoginObject)session.getAttribute("LOGIN_OBJECT");
//		String requestURI = request.getRequestURI();
//		requestURI = requestURI.substring(request.getContextPath().length());
//		if (loginObject == null && !requestURI.startsWith("/sys/login") && !requestURI.startsWith("/ssoLogin/") && !requestURI.startsWith("/mobileoa/"))
//		{
//			if (SysProperties.MUST_LOGIN.equalsIgnoreCase("false"))
//			{
//				loginObject = new LoginObject();
//				loginObject.setPersonId(SysProperties.ADMIN_ID);
//				loginObject.setPersonName("锟斤拷锟斤拷锟斤拷锟斤拷员");
//				loginObject.setLogin(SysProperties.ADMIN_LOGIN);
//				loginObject.setIp(servletRequest.getRemoteAddr());
//				session.setAttribute("LOGIN_OBJECT", loginObject);
//				filterChain.doFilter(servletRequest, servletResponse);
//			} else
//			{
//				forward(request, response, (String)logoutUrlMap.get("LOGIN_OBJECT"));
//				request.setAttribute("error", "锟斤拷录锟斤拷时");
//			}
//		} else
//		{
//			filterChain.doFilter(servletRequest, servletResponse);
//		}
	}

	private String getUri(HttpServletRequest request)
	{
		String uri = request.getRequestURI().split("\\?")[0];
		String ctx = request.getContextPath();
		if (!"/".equals(ctx))
			uri = uri.substring(ctx.length(), uri.length());
		return uri;
	}

	private void forward(HttpServletRequest request, HttpServletResponse response, String forwardUrl)
		throws IOException, ServletException
	{
		response.setCharacterEncoding("UTF-8");
		request.getRequestDispatcher(forwardUrl).forward(request, response);
	}

	public void destroy()
	{
		
		filterConfig = null;
	}
}
